package com.phrp.controller;

import com.phrp.entity.vo.UserSearchDataVo;
import com.phrp.entity.User;
import com.phrp.service.UserService;
import com.phrp.util.returnResult.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.LinkedList;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ssc
 * @since 2024-04-20
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    /**
     * 新增用户
     * @param user
     * @return
     */
    @PostMapping(value = "addUser")
    public ResponseResult addUser(@RequestBody User user){
        return userService.addUser(user);
    }

    /**
     * 查询用户信息
     * @param searchData
     * @return
     */
    @PostMapping(value = "searchUser")
    public ResponseResult searchUser(@RequestBody UserSearchDataVo searchData){
        return userService.searchUser(searchData);
    }

    /**
     * 删除用户信息
     * @param ids
     * @return
     */
    @PostMapping(value = "deleteUser")
    public ResponseResult deleteUser(@RequestBody LinkedList<String> ids){
        return userService.deleteUser(ids);
    }

    /**
     * 修改用户信息
     * @param user
     * @return
     */
    @PostMapping(value = "editUser")
    public ResponseResult editUser(@RequestBody User user){
        return userService.editUser(user);
    }

    /**
     * 重置密码
     * @param ids
     * @return
     */
    @PostMapping(value = "resetPassword")
    public ResponseResult resetPassword(@RequestBody LinkedList<String> ids){
        return userService.resetPassword(ids);
    }

    /**
     * 修改用户状态
     * @return
     */
    @GetMapping(value = "updateStatus")
    public ResponseResult updateStatus(@RequestParam String id, @RequestParam String type){
        return userService.updateStatus(id,type);
    }

}
